<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="项目名称" prop="projectName">
        <el-input v-model="queryParams.projectName" placeholder="请输入项目名称" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="品牌方" prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="department_list" :normalizer="normalizer" placeholder="选择品牌方"
          style="width:217px" />
      </el-form-item>
      <el-form-item label="渠道" prop="channel">
        <el-select v-model="queryParams.channel" placeholder="请选择" clearable>
          <el-option v-for="item in marketing_channel" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['produce:produce-plan:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['produce:produce-plan:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
          @click="handleDelete">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['produce:produce-plan:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getProjectList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" row-key="id" :data="projectList" @selection-change="handleSelectionChange" :default-sort = "{prop: 'id', order: 'descending'}">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column sortable label="项目编号" align="center" prop="id" />
      <el-table-column label="项目名" align="center" prop="projectName" />
      <el-table-column label="品牌方" align="center" prop="deptName" />
      <el-table-column label="渠道" align="center" prop="channel" />
      <el-table-column label="Iot" align="center" prop="isRegisterIot">
        <template slot-scope="scope">
          {{ scope.row.isRegisterIot === 0 ? '不需要' : '需要' }}
        </template>
      </el-table-column>
      <el-table-column label="Oss" align="center" prop="isOss">
        <template slot-scope="scope">
          {{ scope.row.isOss === 0 ? '不需要' : '需要' }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="资管" align="center" prop="isZg">
        <template slot-scope="scope">
          {{ scope.row.isZg === 0 ? '不需要' : '需要' }}
        </template>
      </el-table-column> -->
      <el-table-column label="设备总数" align="center" prop="deviceCount" width="180">
        <template slot-scope="scope">
          <el-button size="mini" style="font-size: 14px;" type="text" @click="toDevice(scope.row)">
            {{ scope.row.deviceCount || 0 }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="商品总数" align="center" prop="goodsCount">
        <template slot-scope="scope">
          <el-button size="mini" style="font-size: 14px;" type="text" @click="toProjectGood(scope.row)">
            {{ scope.row.goodsCount || 0 }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="组织架构" align="center" prop="users" />
      <el-table-column label="算法" align="center" prop="algorithm" />
      <el-table-column label="创建人" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column label="修改人" align="center" prop="updateBy" />
      <el-table-column label="修改时间" align="center" prop="updateTime" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
          <el-button size="mini" type="text" icon="el-icon-search"
            @click="handleDetailCount(scope.row)">查看调用次数</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getProjectList" />

    <!-- 添加或修改项目对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-form-item label="项目名称" prop="projectName">
          <el-input v-model="form.projectName" placeholder="请输入项目名称" style="width:600px" maxlength="20" show-word-limit />
        </el-form-item>
        <el-form-item label="设备总数">
          <el-button v-if="this.edit == false" size="mini" style="font-size: 14px;" type="text"
            @click="handleDeviceDetail()">{{
              this.form.deviceTotal || 0 }}</el-button>
          <span v-else>
            {{ this.form.deviceTotal || 0 }}
          </span>
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="品牌方" prop="deptId">
              <treeselect v-model="form.deptId" :options="department_list" :normalizer="normalizer" placeholder="选择品牌方"
                style="width:217px" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="渠道" prop="channel">
              <el-select v-model="form.channel" placeholder="请选择" clearable>
                <el-option v-for="item in marketing_channel" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="组织架构" prop="users">
              <el-input v-model="form.users" placeholder="请输入组织架构名称" style="width:217px" maxlength="20" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="sim卡供应" prop="simCardSupply">
              <el-select v-model="form.simCardSupply" placeholder="请选择" clearable>
                <el-option v-for="item in simCard_supply" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="抓图策略" prop="snapStrategy">
              <el-select v-model="form.snapStrategyList" placeholder="请选择抓图策略" clearable multiple @change="itemChoose">
                <el-option v-for="item in snap_strategys" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="算法" prop="algorithm">
              <el-select v-model="form.algorithm" placeholder="请选择算法配置" clearable>
                <el-option v-for="dict in dict.type.algo_type" :key="dict.value" :label="dict.label" :value="dict.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="柜子类型" prop="containerType">
              <el-select v-model="form.containerTypeList" placeholder="请选择柜子类型" clearable filterable multiple
                @change="itemChoose">
                <el-option v-for="item in container_type" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="型号组合" prop="modelGroup">
              <el-select v-model="form.modelGroupList" placeholder="请选择型号组合" multiple clearable filterable
                @change="itemChoose">
                <el-option v-for="item in model_group" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="是否支持Oss" prop="isOss">
              <el-select v-model="form.isOss" placeholder="请选择是否需要" clearable>
                <el-option v-for="item in oss_support_list" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否支持Iot" prop="isRegisterIot">
              <el-select v-model="form.isRegisterIot" placeholder="请选择是否需要" clearable>
                <el-option v-for="item in register_to_IOT" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-show="this.form.isOss === 1">
          <el-col :span="12">
            <el-form-item label="图片数据" prop="picValidity">
              <el-select v-model="form.picValidity" placeholder="请选择保留时间" clearable>
                <el-option v-for="item in ossData_image_validity" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="视频数据" prop="videoValidity">
              <el-select v-model="form.videoValidity" placeholder="请选择保留时间" clearable>
                <el-option v-for="item in ossData_video_validity" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <!-- <el-col :span="12">
            <el-form-item label="是否支持资管" prop="isZg">
              <el-select v-model="form.isZg" placeholder="请选择是否需要" clearable>
                <el-option v-for="item in register_to_IOT" :key="item.value" :label="item.label" :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="12" v-show="this.form.isRegisterIot === 1">
            <el-form-item label="业务数据" prop="serviceValidity">
              <el-select v-model="form.serviceValidity" placeholder="请选择保留时间" clearable>
                <el-option v-for="item in database_serviceData_validity" :key="item.value" :label="item.label"
                  :value="item.value" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" style="width:600px" type="text" maxlength="50"
                show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <div style="width:100%;margin-top:10px">
          <div class="formTitle">外设属性</div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="门磁信号源" prop="platformPeripheralProperty.doorSignal">
                  <el-select v-model="form.platformPeripheralProperty.doorSignal" placeholder="请选择门磁信号源" clearable>
                    <el-option v-for="item in gateMagnetic_signal_source" :key="item.value" :label="item.label"
                      :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="客流信号源" prop="platformPeripheralProperty.peopleSignal">
                  <el-select v-model="form.platformPeripheralProperty.peopleSignal" placeholder="请选择客流信号源" clearable>
                    <el-option v-for="item in passengesFlow_signal_source" :key="item.value" :label="item.label"
                      :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="灯控信号源" prop="platformPeripheralProperty.lampSignal">
                  <el-select v-model="form.platformPeripheralProperty.lampSignal" placeholder="请选择灯控信号源" clearable>
                    <el-option v-for="item in lampControl_signal_source" :key="item.value" :label="item.label"
                      :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="语音播放功能" prop="platformPeripheralProperty.voicePlayback">
                  <el-select v-model="form.platformPeripheralProperty.voicePlayback" placeholder="请选择是否配置" clearable>
                    <el-option v-for="item in voicePlayback_setting_choose" :key="item.value" :label="item.label"
                      :value="item.value" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
        <div style="width:100%;margin-top:10px">
          <div class="formTitle">陈列标准</div>
          <el-form-item label="商品总数" prop="goodsTotal">
            <el-button v-if="edit == false" size="mini" style="font-size: 14px;" type="text" @click="handleSkuDetail()">
              {{ this.choooseNum || 0 }}
            </el-button>
            <span v-else>{{ this.form.skuTotal || 0 }}</span>
          </el-form-item>
          <el-row>
            <el-col :span="12">
              <el-form-item label="纯净度(空)" prop="platformDisplayStandard.purityVacant">
                <el-input v-model="form.platformDisplayStandard.purityVacant" placeholder="请输入含空位的纯净度" type="number"
                  style="width:218.33px" oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)"
                  maxlength="3" show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="纯净度" prop="platformDisplayStandard.purity">
                <el-input v-model="form.platformDisplayStandard.purity" placeholder="请输入不含空位的纯净度" type="number"
                  style="width:218.33px" oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)"
                  :max="100" maxlength="3" show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="饱和度" prop="platformDisplayStandard.saturation">
                <el-input v-model="form.platformDisplayStandard.saturation" placeholder="请输入饱和度" type="number"
                  style="width:218.33px" oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)"
                  :max="100" maxlength="3" show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="必铺品率" prop="platformDisplayStandard.essentialRate">
                <el-input v-model="form.platformDisplayStandard.essentialRate" placeholder="请输入必铺品率" type="number"
                  style="width:218.33px" oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)"
                  :max="100" maxlength="3" show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="黄金位纯度(空)" prop="platformDisplayStandard.goldenPurityVacant">
                <el-input v-model="form.platformDisplayStandard.goldenPurityVacant" placeholder="请输入含空位的黄金位纯度"
                  type="number" style="width:218.33px"
                  oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)" maxlength="3"
                  show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="黄金位纯度" prop="platformDisplayStandard.goldenPurity">
                <el-input v-model="form.platformDisplayStandard.goldenPurity" placeholder="请输入不含空位的黄金位纯度" type="number"
                  style="width:218.33px" oninput="if(value<=0)value=0;if(value>=100)value=100;value=parseInt(value)"
                  :max="100" maxlength="3" show-word-limit>
                  <i slot="suffix" style="font-style:normal;margin-right: 10px; line-height: 30px; color: #1e1e1e">%</i>
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!-- <el-form-item label="黄金位层数">
            <el-checkbox-group v-model="goldLayerList" @change="handleGoldenLayerChange">
              <el-checkbox label="1" value="1"></el-checkbox>
              <el-checkbox label="2" value="2"></el-checkbox>
              <el-checkbox label="3" value="3"></el-checkbox>
              <el-checkbox label="4" value="4"></el-checkbox>
              <el-checkbox label="5" value="5"></el-checkbox>
              <el-checkbox label="6" value="6"></el-checkbox>
            </el-checkbox-group>
          </el-form-item> -->
        </div>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看项目名下设备详情列表 -->
    <el-dialog :title="devicesListDialogTitle" :visible.sync="deviceListDialogOpen" width="1400px" append-to-body>
      <!-- 新增设备、批量新增设备 -->
      <!-- <el-button type="primary" @click="handleAddDevice">新 增</el-button> -->
      <!-- <el-button @click="addD">批 量 新 增</el-button> -->
      <!-- 查询结果结果展示 -->
      <el-table v-loading="deviceListLoading" :data="projectDevicelList">
        <!-- <el-table-column type="selection" width="55" align="center" /> -->
        <el-table-column label="设备唯一id" align="center" prop="deviceId" :show-overflow-tooltip="true" />
        <el-table-column label="设备名称" align="center" prop="name" :show-overflow-tooltip="true" />
        <el-table-column label="项目" align="center" prop="projectName" :show-overflow-tooltip="true" />
        <el-table-column label="设备组合" align="center" prop="deviceComposeName" :show-overflow-tooltip="true" />
        <el-table-column label="柜子类型" align="center" prop="containerTypeName" :show-overflow-tooltip="true" />
        <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
        <el-table-column label="用户名" align="center" prop="nickName" :show-overflow-tooltip="true" />
        <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
            >修改</el-button>
            <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
            >删除</el-button>
          </template>
        </el-table-column> -->
      </el-table>
      <pagination v-show="projectDeviceListQueryParams.total > 0" :total="projectDeviceListQueryParams.total"
        :page.sync="projectDeviceListQueryParams.pageNum" :limit.sync="projectDeviceListQueryParams.pageSize"
        @pagination="getMainDeviceList" />
    </el-dialog>

    <!-- 查看项目名下或所有商品详情列表 -->
    <el-dialog :title="skuDetailDialogTitle" :visible.sync="skuDetailDialogOpen" width="1400px" append-to-body>
      <el-table v-loading="skuListLoading" :data="skuList" @selection-change="handleSelectionChange" row-key="skuId"
        ref="skuTable">
        <el-table-column type="selection" width="55" :reserve-selection="true" />
        <el-table-column label="SKU编号" align="center" prop="skuId" :show-overflow-tooltip="true" />
        <el-table-column label="SKU名称" align="center" prop="skuName" :show-overflow-tooltip="true" />
        <el-table-column label="SKU图片" align="center" prop="imageUrl" :show-overflow-tooltip="true">
          <template slot-scope="scope">
            <el-popover trigger="hover" placement="bottom">
              <img slot="reference" :src="scope.row.imageUrl" height="50" v-if="scope.row.imageUrl" />
              <img :src="scope.row.imageUrl" style="height: 200px" v-if="scope.row.imageUrl" />
            </el-popover>
          </template>
        </el-table-column>
        <el-table-column v-if="edit == false" label="绑定V4算法名称" align="center" prop="v4SkuName"
          :show-overflow-tooltip="true" />
        <el-table-column v-if="edit == false" label="V4顶层算法Id" align="center" prop="v4TopSkuId"
          :show-overflow-tooltip="true" />
        <el-table-column v-if="edit == false" label="V4顶层主图" align="center" prop="v4TopSkuPackageUrl">
          <template slot-scope="scope">
            <div>
              <el-popover trigger="hover" placement="bottom" width="400" v-if="scope.row.v4TopSkuPackageUrl">
                <img slot="reference" :src="scope.row.v4TopSkuPackageUrl" height="50"
                  v-if="scope.row.v4TopSkuPackageUrl" />
                <img :src="scope.row.v4TopSkuPackageUrl" style="height: 200px" v-if="scope.row.v4TopSkuPackageUrl" />
              </el-popover>
              <span v-if="!scope.row.v4TopSkuPackageUrl">-</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column v-if="edit == false" label="V4中间层算法Id" align="center" prop="v4MidSkuId"
          :show-overflow-tooltip="true" />
        <el-table-column v-if="edit == false" label="V4中间层主图" align="center" prop="v4MidSkuPackageUrl">
          <template slot-scope="scope">
            <div>
              <el-popover trigger="hover" placement="bottom" width="400" v-if="scope.row.v4MidSkuPackageUrl">
                <img slot="reference" :src="scope.row.v4MidSkuPackageUrl" height="50"
                  v-if="scope.row.v4MidSkuPackageUrl" />
                <img :src="scope.row.v4MidSkuPackageUrl" style="height: 200px" v-if="scope.row.v4MidSkuPackageUrl" />
              </el-popover>
              <span v-if="!scope.row.v4MidSkuPackageUrl">-</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column v-if="edit == false" label="V4底层算法Id" align="center" prop="v4BottomSkuId"
          :show-overflow-tooltip="true" />
        <el-table-column v-if="edit == false" label="V4底层主图" align="center" prop="v4BottomSkuPackageUrl">
          <template slot-scope="scope">
            <div>
              <el-popover trigger="hover" placement="bottom" width="400" v-if="scope.row.v4BottomSkuPackageUrl">
                <img slot="reference" :src="scope.row.v4BottomSkuPackageUrl" height="50"
                  v-if="scope.row.v4BottomSkuPackageUrl" />
                <img :src="scope.row.v4BottomSkuPackageUrl" style="height: 200px"
                  v-if="scope.row.v4BottomSkuPackageUrl" />
              </el-popover>
              <span v-if="!scope.row.v4BottomSkuPackageUrl">-</span>
            </div>
          </template>
        </el-table-column>

        <el-table-column label="SKU品类" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope" v-if="scope.row.classify != null">
            <el-select v-if="edit == false" v-model="scope.row.classify" filterable
              @change="handleClassifyAndBipupinChange(scope.row)">
              <el-option v-for="(item, index) in classify" :key="index" :label="item.label" :value="item.value" />
            </el-select>
            <span v-else>{{ scope.row.classify === 0 ? '本品' : (scope.row.classify === 1 ? '竞品' : '他品') }}</span>
          </template>
        </el-table-column>

        <el-table-column label="是否为必铺品" align="center" :show-overflow-tooltip="true">
          <template slot-scope="scope" v-if="scope.row.classify == 0">
            <el-select v-if="edit == false" v-model="scope.row.bipupin" filterable
              @change="handleClassifyAndBipupinChange(scope.row)">
              <el-option v-for="item in bipupin" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
            <span v-else>{{ scope.row.bipupin === true ? '是' : '否' }} </span>
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true" />
      </el-table>
      <pagination v-show="projectDeviceListQueryParams.total > 0" :total="projectDeviceListQueryParams.total"
        :page.sync="projectDeviceListQueryParams.pageNum" :limit.sync="projectDeviceListQueryParams.pageSize"
        @pagination="getMainDeviceList" />
      <div style="text-align: right;">
        <el-button type="primary" style="margin:10px" @click="handelInsert">确定</el-button>
        <el-button v-if="edit == false" @click="modifyCancel" style="margin:10px">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 查看调用次数的弹窗 -->
    <el-dialog :title="arithmeticCountDialogTitle" :visible.sync="arithmeticCountDialogOpen" width="1400px"
      append-to-body>
      <el-table v-loading="countListLoading" :data="arithmeticCountList" @selection-change="handleSelectionChange"
        row-key="id" ref="CountTable">
        <el-table-column type="selection" width="55" :reserve-selection="true" />
        <el-table-column label="id" align="center" prop="id" :show-overflow-tooltip="true" />
        <el-table-column label="陈列v4算法调用次数" align="center" prop="algoV4Count" :show-overflow-tooltip="true" />
        <el-table-column label="亮度算法调用次数" align="center" prop="brightnessCount" :show-overflow-tooltip="true" />
        <el-table-column label="遮挡识别剩余次数" align="center" prop="coverCount" :show-overflow-tooltip="true" />
        <el-table-column label="油污算法调用次数" align="center" prop="muddyCount" :show-overflow-tooltip="true" />
        <el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true" />
      </el-table>
    </el-dialog>
  </div>
</template>

<script>

import { listProject, getProjectDetail, addProject, updateProject, exportProject, delProject, getArithmeticCount } from "@/api/project/project";
import { batchInsert } from "@/api/projectSku/projectSku";
import { listDeviceModelCompose } from "@/api/device/deviceModelCompose";
import { listSnapStrategy } from "@/api/device/snapStrategy";
import { listContainerType } from "@/api/container/containerType";
import { listDept } from "@/api/system/dept";
import { listUser } from "@/api/system/user";
import { listMainDevice } from "@/api/device/mainDevice";
import Treeselect from "@riophae/vue-treeselect";
import { listSku } from '@/api/sku/sku';
import { getProjectGoodsList } from '@/api/projectSku/projectSku';
import "@riophae/vue-treeselect/dist/vue-treeselect.css";

export default {
  name: "project",
  dicts:['algo_type'],
  components: { Treeselect },
  data() {
    return {
      // // 新增设备弹框
      // addDeviceDialogOpen: false,
      // // 新增设备弹框名
      // addDeviceDialogTitle: '',
      //算法调用次数记录
      arithmeticCountList: [],
      //算法调用次数列表loding
      countListLoading: false,
      choooseNum: '',
      // 项目名下设备列表
      projectDevicelList: [],
      skuList: [],  //商品列表
      // 项目列表
      project_list: [],
      // 设备型号组合列表
      project_model_compose_list: [],
      // 设备型号列表
      project_device_model_list: [],
      // 设备型号列表
      project_device_list: [],
      // 设备型号列表
      project_snap_strategy_list: [],
      // 用户列表
      user_list: [],
      // 品牌方
      department_list: [],
      allProjectList:[],
      // 渠道
      marketing_channel: [
        { label: '零售', value: '零售' },
        { label: '品牌', value: '品牌' },
      ],
      edit: false, //是否是修改
      // 选中的黄金层数
      goldLayerList: [],
      projectSkuList: [],  //项目商品列表
      // 表单数据
      form: {
        deviceTotal: 0,
        skuTotal: 0,
        platformDisplayStandard: {
          bipupinRate: null,
          goldenPurity: null,
          goldenPurityVacant: null,
          goldenTier: null,
          purity: null,
          purityVacant: null,
          saturation: null
        },
        platformPeripheralProperty: {
          doorSignal: null,
          lampSignal: null,
          peopleSignal: null,
          voicePlayback: null
        }
      },
      deptList: [], //品牌方列表
      // 是否注册到我们iot平台
      register_to_IOT: [
        { label: '不需要', value: 0 },
        { label: '需要', value: 1 },
      ],
      // sim卡厂商 量讯、广和通、SIMBOSS，仓颉
      simCard_supply: [
        { label: '量讯', value: '量讯' },
        { label: '广和通', value: '广和通' },
        { label: 'SIMBOSS', value: 'SIMBOSS' },
        { label: '仓颉', value: '仓颉' }
      ],
      // OSS
      oss_support_list: [
        { label: '不需要', value: 0 },
        { label: '需要', value: 1 },
      ],
      // 柜子类型
      container_type: [],
      // 型号组合
      model_group: [],
      // 算法版本
      algorithm_version: [
        { label: '无需算法', value: '无需算法' },
        { label: 'mvt4', value: 'mvt4' },
        { label: '风幕算法', value: '风幕算法' },
      ],
      // 抓图策略列表
      snap_strategys: [],
      // 门磁信号源列表
      gateMagnetic_signal_source: [
        { label: '不上报门动作', value: '0' },
        { label: '主控自带门磁', value: '1' },
        { label: '温控器的门磁', value: '2' },
        { label: '抓拍机门开关', value: '3' },
      ],
      // 客流信号源列表
      passengesFlow_signal_source: [
        { label: '不带客流功能', value: '0' },
        { label: '主控pir', value: '1' },
        { label: '温控器客流上报', value: '2' },
        { label: '抓拍机客流上报', value: '3' },
        { label: '需要客流，后台实现', value: '4' },
      ],
      // 灯控信号源列表
      lampControl_signal_source: [
        { label: '无需控制', value: '0' },
        { label: '主控控制', value: '1' },
        { label: '温控控制', value: '2' },
        { label: '抓拍机控制', value: '3' },
      ],
      // 语音播报功能列表
      voicePlayback_setting_choose: [
        { label: '不需要', value: '0' },
        { label: '需要', value: '1' },
      ],
      // 数据库业务数据保留时间列表
      database_serviceData_validity: [
        { label: '六个月', value: '0' },
        { label: '一年', value: '1' },
        { label: '两年', value: '2' },
        { label: '三年', value: '3' },
        { label: '五年', value: '5' },
      ],
      // oss图片对象数据保留时间列表
      ossData_image_validity: [
        { label: '六个月', value: '0' },
        { label: '一年', value: '1' },
        { label: '两年', value: '2' },
        { label: '三年', value: '3' },
        { label: '五年', value: '5' },
      ],
      // oss视频对象数据保留时间列表
      ossData_video_validity: [
        { label: '六个月', value: '0' },
        { label: '一年', value: '1' },
        { label: '两年', value: '2' },
        { label: '三年', value: '3' },
        { label: '五年', value: '5' },
      ],
      // 设备详情页
      deviceListDialogOpen: false,
      // 设备详情页标题
      devicesListDialogTitle: '',
      // sku详情页
      skuDetailDialogOpen: false,
      // sku详情页标题
      skuDetailDialogTitle: '',
      // 产品缩写代码
      productAbbrList: [],
      // 产品类型代码
      productTypeList: [],
      // 软件代码
      softWareCodeList: [],
      // 硬件代码
      hardWareCodeList: [],
      // 遮罩层
      loading: true,
      // 项目设备遮罩层
      deviceListLoading: true,
      // 商品列表遮罩层
      skuListLoading: true,
      id: '', //项目id
      // 选中数组
      ids: [],
      // 选中项目名数组
      names: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 项目表格数据
      projectList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 项目设备查询参数
      projectDeviceListQueryParams: {
        total: 0,
        pageNum: 1,
        pageSize: 10,
        projectId: ''
      },
      arithmeticCountDialogOpen: false, //算法次数弹窗
      arithmeticCountDialogTitle: '',  //算法次数title
      modifyVisible: false,//商品列表确认修改
      chooseSkuList: [],//复选框选中的商品列表
      classify:
        [{
          value: 0,
          label: '本品'
        }, {
          value: 1,
          label: '竞品'
        }, {
          value: 2,
          label: '他品'
        }],
      bipupin:
        [{
          value: false,
          label: '否'
        }, {
          value: true,
          label: '是'
        }],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectName: null, //项目名
        channel: null,
        planProduceDate: null,
        productLineCode: null,
        productAddr: null,
        softwareCode: null,
        hardwareCode: null,
        expand1: null,
        expand2: null,
        planProduceCount: null,
        removed: null,
        isRegisterIot: null
      },
      // 表单校验
      rules: {
        // isZg: [
        //   { required: true, message: "资管不能为空", trigger: "blur" }
        // ],
        projectName: [
          { required: true, message: "项目名不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "品牌方不能为空", trigger: "blur" }
        ],
        algorithm: [
          { required: true, message: "算法选项不能为空", trigger: "blur" }
        ],
        simCardSupply: [
          { required: true, message: "请选择sim卡供应方", trigger: "blur" }
        ],
        isRegisterIot: [
          { required: true, message: "请选择是否注册到我方iot平台", trigger: "blur" }
        ],
        isOss: [
          { required: true, message: "请选择是否需要支持Oss", trigger: "blur" }
        ],
        platformPeripheralProperty: {
          doorSignal: [
            { required: true, message: "请配置门磁信号源", trigger: "blur" }
          ],
          peopleSignal: [
            { required: true, message: "请配置客流信号源", trigger: "blur" }
          ],
          lampSignal: [
            { required: true, message: "请配置灯控信号源", trigger: "blur" }
          ],
          voicePlayback: [
            { required: true, message: "请配置语音播报功能", trigger: "blur" }
          ],
        }
      }
    };
  },
  created() {
    this.getDeviceModelComposeDetailList();
    //this.getAlljectList();
    this.getProjectList();
    this.getSnapStrategyList();
    this.getContainerTypeList();
    this.getDeptList();
  },
  methods: {
    /** 新增设备操作 */
    // handleAddDevice() {
    //   this.resetDeviceForm();
    //   this.addDeviceDialogOpen = true;
    //   this.addDeviceDialogTitle = "添加设备";
    // },
    /** 转换部门数据结构 */
    /**查看调用次数的弹窗 */
    handleDetailCount(row) {
      this.$router.push({
        path: '/genius-arithmetic/platform-arithmetic-count',
        query: {
          projectId: row.id
        }

      })
      // this.countListLoading = true
      // const params = {
      //   projectId: row.id
      // }
      // getArithmeticCount(params).then((res) => {
      //   if (res.code === 200) {
      //     this.arithmeticCountList = res.rows
      //   }
      // }).finally(() => {
      //   this.countListLoading = false

      // })
      // this.arithmeticCountDialogOpen = true;
      // this.arithmeticCountDialogTitle = "查看调用次数";
    },
    normalizer(node) {
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id: node.deptId,
        label: node.deptName,
        children: node.children
      };
    },
    /** 选择部门 */
    chooseDepartment() {
      //先清空
      this.form.userList = ''
      this.user_list = []
      const params = {
        deptId: parseInt(this.form.deptId)
      }
      listUser(params).then((res) => {
        if (res.code === 200 && res.rows) {
          for (var i = 0; i < res.rows.length; i++) {
            let temp = {
              value: res.rows[i].userId.toString(),
              label: res.rows[i].nickName
            }
            this.user_list.push(temp)
          }
        }
      })
    },
    /** 获取部门（品牌方）列表 */
    getDeptList() {
      listDept().then((res) => {
        if (res.code === 200 && res.data) {
          this.department_list = this.handleTree(res.data, "deptId");
        }
      })
    },
    /** 获取冰柜类型列表 */
    getContainerTypeList() {
      listContainerType().then((res) => {
        console.log("获取到的冰柜类型列表为", res)
        if (res.code === 200 && res.rows) {
          for (var i = 0; i < res.rows.length; i++) {
            let temp = {
              label: res.rows[i].name,
              value: res.rows[i].id.toString()
            }
            this.container_type.push(temp)
          }
        }
      })
    },

    /** 获取抓图策略列表 */
    getSnapStrategyList() {
      listSnapStrategy().then((res) => {
        if (res.code === 200 && res.rows) {
          for (var i = 0; i < res.rows.length; i++) {
            let temp = {
              value: res.rows[i].id.toString(),
              label: res.rows[i].name
            }
            this.snap_strategys.push(temp)
          }
        }
      })
    },
    /** 获取型号组合列表 */
    getDeviceModelComposeDetailList() {
      listDeviceModelCompose().then((res) => {
        if (res.code === 200 && res.rows) {
          for (var i = 0; i < res.rows.length; i++) {
            let temp = {
              value: res.rows[i].id.toString(),
              label: res.rows[i].name
            }
            this.model_group.push(temp)
          }
        }

      })
    },
    /** 多选框点击事件 */
    itemChoose() {
      this.$forceUpdate();
    },
    /** 获取项目列表 */
    getProjectList() {
      this.loading = true;
      listProject(this.queryParams).then((res) => {
        if (res.code === 200 && res.rows) {
          this.projectList = res.rows
          //this.deptList = res.
          this.total = res.total
        }
      }).catch((err) => {
        this.$message.error("项目列表获取失败，原因：" + err.message)
      }).finally(() => {
        this.loading = false;
      })
    },
    /**获取所有项目 */
    getAlljectList() {
      this.loading = true;
      listProject(this.queryParams).then((res) => {
        if (res.code === 200 && res.rows) {
          this.allProjectList = res.rows
        }
      }).catch((err) => {
        this.$message.error("项目列表获取失败，原因：" + err.message)
      }).finally(() => {
        this.loading = false;
      })
    },
    /** 黄金层点击触发 */
    // handleGoldenLayerChange() {
    //   //排序一下
    //   this.goldLayerList.sort()
    // },
    /** 点击sku数量，查看sku详情 */
    handleSkuDetail() {
      this.skuDetailDialogOpen = true
      this.skuDetailDialogTitle = "sku详情"
      this.chooseSkuList = []
    },
    /**更改品类或必铺品后 */
    handleClassifyAndBipupinChange(row) {
      if (this.chooseSkuList == []) {
        return
      }
      this.chooseSkuList.forEach(item => {
        if (item.skuId == row.skuId) {
          item.classify = row.classify
          item.bipupin = row.bipupin
          if (row.classify !== 0) {
            item.bipupin = false
          }
        }
      })
    },
    /** 点击设备数量，查看设备详情 */
    handleDeviceDetail() {
      //if (this.title == "修改项目") {
      this.deviceListDialogOpen = true
      //}
      this.devicesListDialogTitle = "项目名下设备"
      this.projectDeviceListQueryParams.projectId = this.form.id
      this.getMainDeviceList()
    },
    /** 获取主设备列表 */
    getMainDeviceList() {
      this.deviceListLoading = true;
      listMainDevice(this.projectDeviceListQueryParams).then((res) => {
        if (res.code === 200) {
          this.projectDevicelList = res.rows
          this.projectDeviceListQueryParams.total = res.total
        }
      }).catch((err) => {
        this.$message.error("设备列表获取失败，原因：" + err.message)
      }).finally(() => {
        this.deviceListLoading = false;
      })
    },
    /**跳转到项目商品页面 */
    toProjectGood(row) {
      this.$router.push({
        path: '/goods/platform-project-goods',
        query: {
          projectId: row.id
        }

      })
    },
    /**跳转到设备页面 */
    toDevice(row) {
      this.$router.push({
        path: '/genius-device/platform-device',
        query: {
          projectId: row.id
        }

      })
    },
    /** 查看产品信息-获得产品缩写列 */
    getProductAbbrList() {
      // 初始化
      this.productAbbrList = []
      const params = {
        pageNum: 1,
        pageSize: 10000,
        productTypeCode: this.form.productTypeCode
      }
      listProductInfo(params).then((res) => {
        if (res.code === 200) {
          if (res.rows.length > 0) {
            for (var i = 0; i < res.rows.length; i++) {
              let temp = {
                value: res.rows[i].productAbbr,
                label: res.rows[i].productCode
              }
              this.productAbbrList.push(temp)
            }
          }
        }
      })
    },
    /** 查询产品类型下拉 */
    getProductType() {
      const params = {
        pageNum: 1,
        pageSize: 10000
      }
      listProductType(params).then(response => {
        this.productTypeList = response.rows;
        // 下拉框赋默认值
        this.form.productTypeCode = this.productTypeList[0].code;
        // 再去查询列表
        this.getProductAbbrList();
      }).catch((err) => {
        this.$message.error("产品类型列表获取失败！，原因：" + err)
      })
    },
    /** 获取硬件代码列表 */
    getSoftWareList() {
      const params = {
        pageSize: 10000,
        pageNum: 1
      }
      listProductSoftwareRelease(params).then((res) => {
        console.log("软件列表为", res)
        if (res.code === 200) {
          if (res.rows.length > 0) {
            for (var i = 0; i < res.rows.length; i++) {
              let temp = {
                value: res.rows[i].releaseCode,
                label: res.rows[i].releaseName
              }
              this.softWareCodeList.push(temp)
            }
          }
        }
      })
    },
    /** 获取硬件代码列表 */
    getHardWareList() {
      const params = {
        pageSize: 10000,
        pageNum: 1
      }
      listProductHardwareInfo(params).then((res) => {
        console.log("硬件列表为", res)
        if (res.code === 200) {
          if (res.rows.length > 0) {
            for (var i = 0; i < res.rows.length; i++) {
              let temp = {
                value: res.rows[i].hardwareCode,
                label: res.rows[i].hardwareName
              }
              this.hardWareCodeList.push(temp)
            }
          }
        }
      })
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
      this.edit = false;
      this.$refs.skuTable.clearSelection()
      this.choooseNum = 0
    },
    modifyCancel() {
      this.skuDetailDialogOpen = false;
      this.$refs.skuTable.clearSelection()
      this.chooseSkuList = []
    },
    /**新增项目选中商品点确定后*/
    handelInsert() {
      //this.modifyVisible = true;
      // const params = this.chooseSkuList
      // console.log('####params', params)
      this.form.goodsList = this.chooseSkuList
      this.skuDetailDialogOpen = false;
      this.choooseNum = this.chooseSkuList.length
      //this.chooseSkuList = []
    },
    // modifyConfirm() {
    //   this.skuDetailDialogOpen = false;
    //   this.modifyVisible = false;
    // },
    // 表单重置
    reset() {
      this.form = {
        platformDisplayStandard: {
          bipupinRate: null,
          goldenPurity: null,
          goldenPurityVacant: null,
          goldenTier: null,
          purity: null,
          purityVacant: null,
          saturation: null
        },
        platformPeripheralProperty: {
          doorSignal: null,
          lampSignal: null,
          peopleSignal: null,
          voicePlayback: null
        }
      },
        // this.goldLayerList = []
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getProjectList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      //项目列表
      this.ids = selection.map(item => item.id)
      this.names = selection.map(item => item.projectName)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      //选中的商品列表

      this.chooseSkuList = []
      for (let i = 0; i < selection.length; i++) {
        const list = {};
        list.skuId = selection[i].skuId;
        list.classify = selection[i].classify;
        list.bipupin = selection[i].bipupin;
        list.id = selection[i].id;
        list.imageUrl = selection[i].imageUrl;
        list.projectId = this.form.projectId;
        list.skuName = selection[i].skuName;
        list.algoSkuName = selection[i].v4SkuName;
        list.goodsPoolId = selection[i].id;
        if (list.classify !== 0) {
          list.bipupin = false;
        }
        this.chooseSkuList.push(list)
      }
      console.log('选择商品',this.chooseSkuList);
      
      // const list={};
      // for(let i=0;i<selection.length;i++){
      //    list.skuId = selection[i].skuId;
      //    list.classify = selection[i].classify;
      //    list.bipupin = selection[i].bipupin;
      //    list.imageUrl = selection[i].imageUrl;
      //    list.skuId = selection[i].skuId;
      //    if(list.classify!==0){
      //    list.skuName = selection[i].skuName;
      //     list.bipupin = 0;
      //    }
      //   this.chooseSkuList.push(list)
      // }
      //this.chooseSkuList = selection
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加项目";
      //获取设备列表总数  用没有绑定设备的接口
      listMainDevice().then((res) => {
        if (res.code === 200) {
          this.form.deviceTotal = res.total
          this.$forceUpdate()
        }
      }).catch((err) => {
        this.$message.error("设备列表获取失败，原因：" + err.message)
      })
      //获取商品池总数
      listSku().then((res) => {
        if (res.code === 200) {
          res.rows.forEach((item)=>{
            if(item.v4SkuName){
              this.skuList.push(item)
            }
          })
          //this.skuList = res.rows
          // this.form.skuTotal = res.total
          this.$forceUpdate()
        }
      }).catch((err) => {
        this.$message.error("商品列表获取失败，原因：" + err.message)
      }).finally(() => {
        this.skuListLoading = false
        this.$forceUpdate()
      })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      this.id = row.id || this.ids

      this.edit = true;
      // 获取项目详情
      getProjectDetail(this.id).then(response => {
        this.form = response.data;
        // if(response.data.users){
        //   this.form.userList = response.data.users.split(',')
        // }
        if (response.data.containerType) {
          this.form.containerTypeList = response.data.containerType.split(',')
        }
        if (response.data.platformPeripheralProperty === null) {
          this.form.platformPeripheralProperty = {
            doorSignal: null,
            lampSignal: null,
            peopleSignal: null,
            voicePlayback: null
          }
        }
        if (response.data.platformDisplayStandard === null) {
          this.form.platformDisplayStandard = {
            bipupinRate: null,
            goldenPurity: null,
            goldenPurityVacant: null,
            goldenTier: null,
            purity: null,
            purityVacant: null,
            saturation: null
          }
        }
        // if (response.data.platformDisplayStandard && response.data.platformDisplayStandard.goldenTier) {
        //   this.goldLayerList = response.data.platformDisplayStandard.goldenTier.split(',')
        // }
        if (response.data.modelGroup) {
          this.form.modelGroupList = response.data.modelGroup.split(',')
        }
        if (response.data.snapStrategy) {
          this.form.snapStrategyList = response.data.snapStrategy.split(',')
        }
        // 获取项目下的设备数量
        const params = {
          projectId: this.id
        }
        listMainDevice(params).then((res) => {
          if (res.code === 200) {
            this.form.deviceTotal = res.total
            this.$forceUpdate()
          }
        }).catch((err) => {
          this.$message.error("设备列表获取失败，原因：" + err.message)
        })
        //获取所有的商品
        if (this.edit == false) {
          this.skuListLoading = true
          listSku().then((res) => {
            if (res.code === 200) {
              this.skuList = res.rows
              this.form.skuTotal = res.total
              this.$forceUpdate()
            }
          }).catch((err) => {
            this.$message.error("商品列表获取失败，原因：" + err.message)
          }).finally(() => {
            this.skuListLoading = false
            this.$forceUpdate()
          })
        } else {
          const params = {
            projectId: this.id
          }
          getProjectGoodsList(params).then((res) => {
            if (res.code === 200) {
              this.skuList = res.rows
              this.form.skuTotal = res.total
            }
          }).catch((err) => {
            this.$message.error("你没有绑定商品" + err.message)
          }).finally(() => {
            this.skuListLoading = false
            this.$forceUpdate()
          })
        }
        this.open = true;
        this.title = "修改项目";
      });



    },
    /** 提交按钮 */
    submitForm() {
      // 转字符串
      if (this.form.containerTypeList) {
        this.form.containerType = this.form.containerTypeList.join(',')
      }
      // if(this.form.userList){
      //   this.form.users = this.form.userList.join(',')
      // }
      if (this.form.modelGroupList) {
        this.form.modelGroup = this.form.modelGroupList.join(',')
      }
      // if (this.goldLayerList) {
      //   this.form.platformDisplayStandard.goldenTier = this.goldLayerList.join(',')
      // }
      if (this.form.snapStrategyList) {
        this.form.snapStrategy = this.form.snapStrategyList.join(',')
      }
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateProject(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getProjectList();
            });
          } else {
            addProject(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getProjectList();
            });
          }
        }
      });
      this.$refs.skuTable.clearSelection()
      this.choooseNum = 0
      this.edit = false;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      if(row.deviceCount > 0){
        this.$message.warning("请先将项目下的设备解绑，再进行删除");
        return;
      }
      const ids = row.id || this.ids;
      const names = row.projectName || this.names
      this.$modal.confirm('是否确认删除项目名为"' + names + '"的数据项？').then(function () {
        // 修改为逻辑删除
        return delProject(ids);
      }).then(() => {
        this.getProjectList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/genius/platform-project/export', {
        ...this.queryParams
      }, `project_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style lang="scss">
.formTitle {
  width: 100%;
  text-align: center;
  margin: 15px 0 15px 0;
  font-weight: border;
  font-size: 20px
}</style>
